import { defineComponent, PropType } from "vue";
import * as iconsSvg from '@ant-design/icons-svg';
import Icon from '@ant-design/icons-vue/es/components/AntdIcon'

const iconsMap: {
    [key: string]: any;
} = iconsSvg


export default defineComponent({
    name: 'Icon',
    props: {
        name: {
            type: String as PropType<string>,
            default: ''
        },
    },
    setup(props, ctx) {

        const { name } = props;

        const svg = iconsMap[name];

        if (svg == undefined) {
            // console.error(`The icon name ${name} doesn't exist!`)
        }
        return !svg ? () => { <></> } : () => <Icon {...props} icon={svg} />;
    },
});
